<?php
  require(dirname(__FILE__)."/../RequestMethod.php");
  require(dirname(__FILE__)."/../model/DepartmentModel.php");
  class ResolveController extends RequestMethod{
      private $departModel = null;
      /**
      *构造函数，实例化对象
      */
      public function __construct($urlArr){
          $this->departModel = new UserModel();
          parent::__construct($urlArr);
      }
      /**
      *GET请求
      */
      public function doGet(){
          $action = $_GET['action'];
      }
      /**
      *POST请求
      */
      public function doPost(){
        $action = $_GET['action'];
          switch ($action) {
            case 'list':
              $termArr = $_POST['term'];
              $result=$this->departModel->findDepartList($termArr);
              break;
            case 'add':
              $depart = $_POST['depart'];
              $result = $this->departModel->add($depart);
              break;
            case 'mod':
              $depart = $_POST['depart'];
              $result = $this->departModel->update($depart);
              break;
            case 'checkDepart':
              $departName = $_POST['departName'];
              $result = $this->departModel->checkName($departName);
              break;
            case 'status':
              $status = $_POST['status'];
              $result = $this->departModel->changeStatus($status);
              break;
            case 'del':
              $id = $_POST['id'];
              $result = $this->departModel->delete($id);
              break;
          }
        echo json_encode($result);
      }
  }
?>
